const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
    mode: 'development',
    entry: './src/main.js',
    output: {
      filename: 'bundle.js',
      path: path.join(__dirname, 'dist'),
    },
    module: {
      rules: [
        {
          test: /\.vue$/,
          use: 'vue-loader',
        },
        {
          test: /\.js$/,
          use: 'babel-loader',
          exclude: /node_modules/
        },
        {
          test:/\.css$/,
          use:['style-loader','css-loader']
        },
        {
          test: /\.less/,
          use: ['style-loader','css-loader','less-loader']
        },
        {
          test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
          use: {
              loader: 'url-loader',
              options: {
                limit: 10*1024,
                esModule: false
              }
          },
        },
      ]
    },
    plugins: [
      new webpack.DefinePlugin({
        BASE_URL: '"./"'
      }),
      new HtmlWebpackPlugin({
        title: 'Hello Vue',
        template: './public/index.html',
        filename: 'index.html'
      }),
      new VueLoaderPlugin()
    ]
  }